<?php

namespace App\Model;

use Hyperf\Database\Model\Relations\BelongsTo;

/**
 * @property integer $id
 * @property integer $meeting_id
 * @property integer $user_id
 * @property integer $type
 * @property string $username
 * @property string $phone
 * @property string $wechat_code
 * @property string $fields
 * @property \Carbon\Carbon $last_sign_at
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 */
class Sign extends Model
{
    const TYPE_IN = 1; //签到
    const TYPE_OUT = 2; //签退
    const TYPE_LATER_IN = 3; //补签到
    const TYPE_LATER_OUT = 4; //补签退

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'sign';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ["id", "meeting_id", "user_id", "type", "username", "phone", "wechat_code", "fields", "last_sign_at", "created_at", "updated_at"];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ["id"=>"integer", "meeting_id"=>"integer", "user_id"=>"integer", "type"=>"integer","created_at"=>"datetime", "updated_at"=>"datetime", "last_sign_at"=>"datetime"];

    public function meeting(): BelongsTo
    {
        return $this->belongsTo(Meeting::class, 'meeting_id', 'id');
    }
}